#coding=utf-8
import utils

create_scode_sql = '''
create table if not exists scode
    (id int not null primary key auto_increment,
    code char(6) not null,
    name tinytext not null);
'''

def get_scodes(con):
    c = con.cursor()
    c.execute('select code from scode order by code')
    rs = c.fetchall()
    c.close()    
    return [r[0] for r in rs]

def get_name(con, code):
    c = con.cursor()
    c.execute('select name from scode where code = %s', code)
    r = c.fetchone()
    c.close()
    if not r:
        return None
    return r[0]

def is_st(con, code):
    n = get_name(con, code)
    if n.find('S') != -1 or n.find('s') != -1:
        return True
    else:
        return False
    
